﻿<%@ Page Title="" Language="C#" MasterPageFile="~/App_SiteMasterPage/Site.Master"
    AutoEventWireup="true" CodeBehind="AddRoute.aspx.cs" Inherits="eProject.Web.UI.AddRoutePage" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="script" runat="server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="LeftContent" runat="server">
    <div id="widget-categories" class="widget widget-categories">
        <div class="widget-inner">
            <div class="widget-title">
                <h5>
                    Routes</h5>
            </div>
            <div class="widget-content">
                <ul>
                    <li><a class="add" href="AddRoute.aspx">Add New</a></li>
                    <li><a href="RoutesManagement.aspx">List Routes</a></li>
                </ul>
            </div>
        </div>
    </div>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="RightContent" runat="server">
    <div class="widget">
        <div class="widget-inner">
            <div class="widget-title">
                <h5>
                    Add new Route
                </h5>
            </div>
            <div class="widget-content">
                <div class="frm">
                    <div id="tabs">
                        <ul>
                            <li id="liRouteInfo" runat="server"><a href="#tabs-1">Route Info</a></li>
                            <li id="liRouteSchedule" visible="false" runat="server"><a href="#tabs-2">Schedule</a></li>
                            <li id="liRouteSeat" visible="false" runat="server"><a href="#tabs-3">Ticket Price</a></li>
                        </ul>
                        <div id="tabs-1">
                            <div runat="server" id="divRouteInfo">
                                <!--[if lt IE 9]><div class="ie"><![endif]-->
                                <asp:ValidationSummary ID="sumRegister" runat="server" ValidationGroup="InsertRoute"
                                    CssClass="frmValidation" />
                                <fieldset>
                                    <dl>
                                        <dt>
                                            <label>
                                                Plane Code:</label><br />
                                            <span>Please choose ID of Plane</span> </dt>
                                        <dd>
                                            <asp:DropDownList ID="ddlPlaneId" runat="server">
                                            </asp:DropDownList>
                                        </dd>
                                    </dl>
                                    <dl>
                                        <dt>
                                            <label>
                                                From:</label><br />
                                            <span>Please choose a City</span> </dt>
                                        <dd>
                                            <asp:DropDownList ID="ddlFrom" runat="server">
                                            </asp:DropDownList>
                                            <asp:CustomValidator ID="cusFrom" runat="server" CssClass="txtError" ValidationGroup="InsertRoute"
                                                Text="*" ClientValidationFunction="cusFrom_ClientValidate" Display="Dynamic" />
                                        </dd>
                                    </dl>
                                    <dl>
                                        <dt>
                                            <label>
                                                To :</label><br />
                                            <span>Please choose one city</span> </dt>
                                        <dd>
                                            <asp:DropDownList ID="ddlTo" runat="server">
                                            </asp:DropDownList>
                                            <asp:CustomValidator ID="cusTo" runat="server" CssClass="txtError" ValidationGroup="InsertRoute"
                                                Text="*" ClientValidationFunction="cusTo_ClientValidate" Display="Dynamic" />
                                        </dd>
                                    </dl>
                                    <dl>
                                        <dt>
                                            <label>
                                                Distance :</label><br />
                                            <span>Please insert distance</span> </dt>
                                        <dd>
                                            <asp:TextBox ID="txtDistance" runat="server" placeholder="Distance (km)" Width="190px"></asp:TextBox>
                                            <asp:RequiredFieldValidator ID="rfvDistance" CssClass="txtError" ControlToValidate="txtDistance"
                                                runat="server" ErrorMessage="Distance is empty" Text="*" Display="Dynamic" ValidationGroup="InsertRoute" />
                                            <asp:RegularExpressionValidator ID="revDistance" CssClass="txtError" runat="server"
                                                Text="*" Display="Dynamic" ValidationGroup="InsertRoute" ControlToValidate="txtDistance"
                                                ValidationExpression="[0-9]+" ErrorMessage="Input integer" />
                                        </dd>
                                    </dl>
                                </fieldset>
                                <fieldset class="div-button">
                                    <div>
                                        <asp:Button ID="btnSubmit" runat="server" CssClass="btn button1" ValidationGroup="InsertRoute"
                                            Text="Save" />
                                        <input class="btn button2" name="btn_cancel" value="Reset" type="reset" id="btnReset" />
                                    </div>
                                </fieldset>
                                <!--[if lt IE 9]></div><![endif]-->
                            </div>
                        </div>
                        <div id="tabs-2">
                            <div runat="server" visible="false" id="divRouteSchedule">
                                <asp:ValidationSummary ID="ValidationSummary1" runat="server" ValidationGroup="InsertSchedule"
                                    CssClass="frmValidation" />
                                <fieldset>
                                    <dl>
                                        <dt>
                                            <label>
                                                Effect Date:</label><br />
                                            <span>Please choose date</span> </dt>
                                        <dd>
                                            <asp:TextBox ID="txtEffectDate" placeholder="dd/mm/yyyy" ValidationGroup="InsertRoute"
                                                runat="server" />
                                            <asp:RequiredFieldValidator ID="rfvEffectDate" ControlToValidate="txtEffectDate"
                                                runat="server" Text="*" CssClass="txtError" ValidationGroup="InsertSchedule"
                                                ErrorMessage="Input effect date." />
                                        </dd>
                                    </dl>
                                    <dl>
                                        <dt>
                                            <label>
                                                Avalable Status:</label></dt>
                                        <dd>
                                            <asp:CheckBox ID="chkAvailable" runat="server" ValidationGroup="InsertRoute" Text="Available" />
                                        </dd>
                                    </dl>
                                    <dl>
                                        <dt>
                                            <label>
                                                Departure Time:</label><br />
                                            <span>hh:mm</span> </dt>
                                        <dd>
                                            <asp:TextBox ID="txtDepartureTime" runat="server" placeholder="Departure time (hh:mm)" Text="Available" />
                                            <asp:RequiredFieldValidator ID="rfvDepartureTime" ControlToValidate="txtDepartureTime"
                                                runat="server" Text="*" CssClass="txtError" ValidationGroup="InsertSchedule"
                                                ErrorMessage="Input aeparture time." />
                                        </dd>
                                    </dl>
                                    <dl>
                                        <dt>
                                            <label>
                                                Arrival Time:</label><br />
                                            <span>hh:mm</span> </dt>
                                        <dd>
                                            <asp:TextBox ID="txtArrivalTime" runat="server" placeholder="Arrival time (hh:mm)" Text="Available" />
                                            <asp:RequiredFieldValidator ID="rfvArrivalTime" ControlToValidate="txtArrivalTime"
                                                runat="server" Text="*" CssClass="txtError" ValidationGroup="InsertSchedule"
                                                ErrorMessage="Input arrival time." />
                                        </dd>
                                    </dl>
                                    <dl>
                                        <dt>
                                            <label>
                                                Schedule Type:</label></dt>
                                        <dd>
                                            <asp:RadioButtonList ID="rdlScheduleType" ValidationGroup="InsertSchedule" runat="server"
                                                RepeatDirection="Horizontal">
                                                <asp:ListItem Value="One" Selected="True">One</asp:ListItem>
                                                <asp:ListItem Value="EveryDay">Every day</asp:ListItem>
                                                <asp:ListItem Value="Week">Week</asp:ListItem>
                                            </asp:RadioButtonList>
                                            <asp:Panel ID="lstSchedule" Style="display: none" ValidationGroup="InsertSchedule"
                                                runat="server">
                                                <asp:CheckBoxList ID="chkListSchedule" runat="server" RepeatDirection="Horizontal"
                                                    RepeatColumns="4">
                                                    <asp:ListItem Value="Monday">Monday</asp:ListItem>
                                                    <asp:ListItem Value="Tuesday">Tuesday</asp:ListItem>
                                                    <asp:ListItem Value="Wednesday">Wednesday</asp:ListItem>
                                                    <asp:ListItem Value="Thursday">Thursday</asp:ListItem>
                                                    <asp:ListItem Value="Friday">Friday</asp:ListItem>
                                                    <asp:ListItem Value="Saturday">Saturday</asp:ListItem>
                                                    <asp:ListItem Value="Sunday">Sunday</asp:ListItem>
                                                </asp:CheckBoxList>
                                                <asp:CustomValidator ID="cusSchedule" runat="server" CssClass="txtError" ValidationGroup="InsertSchedule"
                                                    Text="*" ClientValidationFunction="cusSchedule_ClientValidate" Display="Dynamic" />
                                            </asp:Panel>
                                        </dd>
                                    </dl>
                                </fieldset>
                                <fieldset class="div-button">
                                    <div>
                                        <asp:Button ID="btnInsertSchedule" runat="server" CssClass="btn button1" ValidationGroup="InsertSchedule"
                                            Text="Save" />
                                        <input class="btn button2" name="btn_cancel" value="Reset" type="reset" id="ResetSchedule" />
                                    </div>
                                </fieldset>
                            </div>
                        </div>
                        <div id="tabs-3">
                            <div runat="server" visible="false" id="divRouteSeat">
                                <asp:ValidationSummary ID="sumPrice" runat="server" ValidationGroup="InsertPrice"
                                    CssClass="frmValidation" />
                                <fieldset>
                                    <dl>
                                        <dt>
                                            <label>
                                                Seat Class:</label><br />
                                            <span>Please choose seat class</span> </dt>
                                        <dd>
                                            <asp:DropDownList ID="ddlSeatClass" runat="server">
                                            </asp:DropDownList>
                                        </dd>
                                    </dl>
                                    <dl>
                                        <dt>
                                            <label>
                                                Price:</label><br />
                                            <span>dollar</span> </dt>
                                        <dd>
                                            <asp:TextBox ID="txtSeatPrice" runat="server" placeholder="Ticket Price (dollar)" />
                                            <asp:RequiredFieldValidator ID="rfvSeatPrice" ControlToValidate="txtSeatPrice" runat="server"
                                                Text="*" CssClass="txtError" ValidationGroup="InsertPrice" ErrorMessage="Input seat price." />
                                            <asp:RegularExpressionValidator ID="revPrice" runat="server" Text="*" ValidationExpression="[0-9]+"
                                                ControlToValidate="txtSeatPrice" CssClass="txtError" ValidationGroup="InsertPrice"
                                                ErrorMessage="Insert integer." />
                                        </dd>
                                    </dl>
                                </fieldset>
                                <fieldset class="div-button">
                                    <div>
                                        <asp:Button ID="btnInsertPrice" runat="server" CssClass="btn button1" ValidationGroup="InsertPrice"
                                            Text="Save" />
                                        <input class="btn button2" name="btn_cancel" value="Reset" type="reset" id="ResetPrice" />
                                    </div>
                                </fieldset>
                                <fieldset class="div-button">
                                    <div>
                                        <asp:GridView ID="grvTicketPrice" CssClass="tbStyles" runat="server" AllowPaging="True"
                                            DataKeyNames="Id" AutoGenerateColumns="False" EmptyDataText="You dont have any ticket price!">
                                            <Columns>
                                                <asp:TemplateField HeaderText="Seat Class">
                                                    <ItemTemplate>
                                                        <asp:Literal ID="litSeatName" runat="server" Text='<%# GetSeatName(Eval("SeatClassId"))%>'></asp:Literal>
                                                    </ItemTemplate>
                                                    <ItemStyle HorizontalAlign="Center" />
                                                </asp:TemplateField>
                                                <asp:BoundField DataField="Price" HeaderText="Ticket Price" />
                                                <asp:TemplateField HeaderText="Delete">
                                                    <ItemTemplate>
                                                        <asp:ImageButton ID="btnDelete" runat="server" CausesValidation="False" CommandName="Delete"
                                                            ImageUrl="~/Images/Icons/delete.png" />
                                                    </ItemTemplate>
                                                    <ItemStyle HorizontalAlign="Center" />
                                                </asp:TemplateField>
                                            </Columns>
                                        </asp:GridView>
                                    </div>
                                </fieldset>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script type="text/javascript">

        function cusTo_ClientValidate(sender, args) {
            var from = $('#<%=ddlFrom.ClientID%>');
            var to = $('#<%=ddlTo.ClientID%>');
            if (from.val() == to.val()) {
                sender.errormessage = "Destination can't equal Origin.";
                args.IsValid = false;
            }
            else
                args.IsValid = true;
        }

        function cusFrom_ClientValidate(sender, args) {
            var from = $('#<%=ddlFrom.ClientID%>');
            var to = $('#<%=ddlTo.ClientID%>');
            if (from.val() == to.val()) {
                sender.errormessage = "Origin can't equal Destination.";
                args.IsValid = false;
            }
            else
                args.IsValid = true;
        }

        function cusSchedule_ClientValidate(sender, args) {
            var choose = $("#<%=rdlScheduleType.ClientID%> input:checked").val();
            if(choose == "Week")
            {
                var lstBox = $('#<%=chkListSchedule.ClientID%> :checkbox:checked').length;
                if(lstBox <= 0)
                {
                    sender.errormessage = "choose day for schedule.";
                    $("#<%=chkListSchedule.ClientID%>").css("border-color", "red");
                    args.IsValid = false;
                }
                else
                {
                    $("#<%=chkListSchedule.ClientID%>").css("border-color","");
                    args.IsValid = true;
                }
            }
        }

        $(function () {

            $("#<%=txtEffectDate.ClientID %>").datepicker({
                dateFormat: "dd/mm/yy",
                minDate: 0,
                changeMonth: true,
                showOn: "both",
                buttonImage: "/Images/Icons/calendar.gif",
                buttonImageOnly: true,
            });

            $("#<%=rdlScheduleType.ClientID%> input:radio").change(function () {
                if (this.checked) {
                    if (this.value == "Week") {
                        $("#<%=lstSchedule.ClientID%>").show('slow');
                    }
                    else {
                       $("#<%=lstSchedule.ClientID%>").hide('fast');
                    }
                }
            });

            $("#<%=txtDepartureTime.ClientID %>").mask("99:99");
            $("#<%=txtArrivalTime.ClientID %>").mask("99:99");
            $("#<%=txtEffectDate.ClientID %>").mask("99/99/9999");
            $('#tabs').tabs();
        });
    </script>
</asp:Content>
